import { defHttp } from '/@/utils/http/axios';
import { ProfessionModel, WebsiteProfessionTableRecordModel } from '../model/websiteProfessionModel';
import { ErrorMessageMode } from "/#/axios";

enum Api {
  WEBSITE_PROFESSION_PAGE = '/jxxhWebsite/websiteprofession/getProfessionVosPage',
  GET_PROFESSIONVO_BY_ID = '/jxxhWebsite/websiteprofession/',
  PROFESSIONVO_SAVE = '/jxxhWebsite/websiteprofession/save',
  PROFESSIONVO_UPDATE = '/jxxhWebsite/websiteprofession/updateById',
  PROFESSIONVO_REMOVE = '/jxxhWebsite/websiteprofession/logicalRemoveById/',
  GET_PROFESSION_LIST = '/jxxhWebsite/websiteprofession/getProfessionList',
}

/**
 * @description: Get sample list value
 */

export const getProfessionListApi = (params: Object) =>
  defHttp.get<WebsiteProfessionTableRecordModel>(
    {url: Api.GET_PROFESSION_LIST,params },
    { errorMessageMode: 'message' }
  );

export const professionPageListApi = (params: Object) =>
  defHttp.get<WebsiteProfessionTableRecordModel>(
    {url: Api.WEBSITE_PROFESSION_PAGE,params },
    { errorMessageMode: 'message' }
  );

export const getProfessionVoByIdApi = (id) =>
  defHttp.get<ProfessionModel>(
    {url: Api.GET_PROFESSIONVO_BY_ID+id },
    { errorMessageMode: 'message' }
  );

export function professionSaveApi(params: ProfessionModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<ProfessionModel>(
    {
      url: Api.PROFESSIONVO_SAVE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export function professionUpdateApi(params: ProfessionModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.put<ProfessionModel>(
    {
      url: Api.PROFESSIONVO_UPDATE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export const logicalRemoveById = (id) =>
  defHttp.delete<ProfessionModel>(
    {url: Api.PROFESSIONVO_REMOVE+id },
    { errorMessageMode: 'message' }
  );
